package com.aistar.service.job.impl;

import com.aistar.mapper.DeliveryMapper;
import com.aistar.mapper.EmployeeCollectionMapper;
import com.aistar.mapper.EmployeeMapper;
import com.aistar.mapper.ResumeMapper;
import com.aistar.model.entity.Delivery;
import com.aistar.model.entity.Employee;
import com.aistar.model.entity.Recruitment;
import com.aistar.model.entity.Resume;
import com.aistar.service.job.IIndexService;
import com.aistar.util.ItemUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;

@Service
public class IndexServiceImpl implements IIndexService {
    @Autowired
    private ResumeMapper resumeMapper;
    @Autowired
    private DeliveryMapper deliveryMapper;
    @Autowired
    private EmployeeMapper employeeMapper;
    @Autowired
    private EmployeeCollectionMapper employeeCollectionMapper;

    @Override
    public List<Integer> countDelivery(Integer employeeId) {
        ItemUtil itemUtil = new ItemUtil();
        List<Employee> employeeList=employeeMapper.findAll();
        List<List<Integer>> recruitmentList=new ArrayList<>();
        List<Integer> recruitment=new ArrayList<>();
        for (Employee employee1 : employeeList) {
            List<Integer> recruitmentList1=employeeCollectionMapper.findByEmployeeId(employee1.getId());
            for (Integer id : recruitmentList1) {
                recruitment.add(id);
            }
            recruitmentList.add(recruitmentList1);
        }

        return itemUtil.LikeRecruitment(employeeList,recruitmentList,employeeId,recruitment);
    }
}
